/**
 * 
 */
package co.fitstart.admin.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dynamic;
import com.demo2do.core.persistence.annotation.Limit;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.credit.product.CreditProduct;
import co.fitstart.entity.credit.product.CreditProductType;

/**
 * @author hooutao
 *
 */
@Dynamic("hibernate")
public interface CreditProductDao {
    
    /**
     * list credit-products by page
     * 
     * @param type
     * @param beginIndex
     * @param maxResult
     * @return
     */
    @Limit
    @Query("FROM CreditProduct product WHERE product.type = :type ORDER BY product.weight DESC, createTime DESC")
    public List<CreditProduct> list(@Variable("type")CreditProductType type, @Variable("beginIndex") int beginIndex, @Variable("maxResult") int maxResult);
    
    /**
     * list sticky credit-product
     * 
     * @param type
     * @return
     */
    @Query("FROM CreditProduct product WHERE product.disabled = false AND product.type = :type AND product.weight > 100  ORDER BY product.weight ASC")
    public List<CreditProduct> list(@Variable("type")CreditProductType type);
    
}
